package org.example.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 实体类，它是数据的载体
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Dept{

    // 部门编号
    private int deptId;
    // 部门名称
    private String deptName;
    // 部门地址
    private String deptLoc;

    public static Dept map(ResultSet rs) throws SQLException {
        Dept dept = new Dept();
        int deptId = rs.getInt("dept_id");
        String deptName = rs.getString("dept_name");
        String deptLoc = rs.getString("dept_loc");
        dept.setDeptId(deptId);
        dept.setDeptName(deptName);
        dept.setDeptLoc(deptLoc);
        return dept;
    }
}
